﻿<phone:PhoneApplicationPage
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:wp7Chess="clr-namespace:WP7Chess"
    xmlns:ic="clr-namespace:Microsoft.Expression.Interactivity.Core;assembly=Microsoft.Expression.Interactions" 
    x:Class="WP7Chess.MainPage"
    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="696"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    shell:SystemTray.IsVisible="True"
    xmlns:local="clr-namespace:WP7Chess"
    local:TiltEffect.IsTiltEnabled="True">
	<phone:PhoneApplicationPage.ApplicationBar>
		<shell:ApplicationBar Opacity="1">
			<shell:ApplicationBarIconButton IconUri="/icons/appbar.new.circle.dark.png" IsEnabled="True" Text="new game" x:Name="NewGame" Click="NewGame_Click"/>
			<shell:ApplicationBarIconButton IconUri="/icons/appbar.feature.settings.rest.png" IsEnabled="True" Text="settings" x:Name="Settings" Click="Settings_Click"/>
			<shell:ApplicationBarIconButton IconUri="/icons/appbar.questionmark.rest.png" IsEnabled="True" Text="about" x:Name="About" Click="About_Click"/>
		</shell:ApplicationBar>
	</phone:PhoneApplicationPage.ApplicationBar>

    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot" Background="Transparent">
    	<VisualStateManager.VisualStateGroups>
    		<VisualStateGroup x:Name="PlayerInfo" ic:ExtendedVisualStateManager.UseFluidLayout="True">
    			<VisualStateGroup.Transitions>
    				<VisualTransition GeneratedDuration="0:0:2">
    					<VisualTransition.GeneratedEasingFunction>
    						<CubicEase EasingMode="EaseInOut"/>
    					</VisualTransition.GeneratedEasingFunction>
    				</VisualTransition>
    			</VisualStateGroup.Transitions>
    			<VisualState x:Name="PlayerInfoHidden">
    				<Storyboard>
    					<DoubleAnimation Duration="0" To="90" Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationX)" Storyboard.TargetName="border" d:IsOptimized="True"/>
    					<DoubleAnimation Duration="0" To="-68" Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateY)" Storyboard.TargetName="border" d:IsOptimized="True"/>
    					<DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="border" d:IsOptimized="True"/>
    					<DoubleAnimation Duration="0" To="90" Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationX)" Storyboard.TargetName="border1" d:IsOptimized="True"/>
    					<DoubleAnimation Duration="0" To="65" Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateY)" Storyboard.TargetName="border1" d:IsOptimized="True"/>
    					<DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="border1" d:IsOptimized="True"/>
    				</Storyboard>
    			</VisualState>
                <VisualState x:Name="PlayerInfoVisible">
                    <Storyboard x:Name="playerInfoVisibleStoryboard" Completed="playerInfoVisibleStoryboard_Completed">
                    	<DoubleAnimation Duration="0" To="0.7" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="playerIntroPannel" d:IsOptimized="True"/>
                    	<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.HorizontalAlignment)" Storyboard.TargetName="border1">
                    		<DiscreteObjectKeyFrame KeyTime="0">
                    			<DiscreteObjectKeyFrame.Value>
                    				<HorizontalAlignment>Stretch</HorizontalAlignment>
                    			</DiscreteObjectKeyFrame.Value>
                    		</DiscreteObjectKeyFrame>
                    	</ObjectAnimationUsingKeyFrames>
                    	<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.VerticalAlignment)" Storyboard.TargetName="border1">
                    		<DiscreteObjectKeyFrame KeyTime="0">
                    			<DiscreteObjectKeyFrame.Value>
                    				<VerticalAlignment>Stretch</VerticalAlignment>
                    			</DiscreteObjectKeyFrame.Value>
                    		</DiscreteObjectKeyFrame>
                    	</ObjectAnimationUsingKeyFrames>
                    	<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.HorizontalAlignment)" Storyboard.TargetName="border">
                    		<DiscreteObjectKeyFrame KeyTime="0">
                    			<DiscreteObjectKeyFrame.Value>
                    				<HorizontalAlignment>Stretch</HorizontalAlignment>
                    			</DiscreteObjectKeyFrame.Value>
                    		</DiscreteObjectKeyFrame>
                    	</ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
    		<VisualStateGroup x:Name="PageState" ic:ExtendedVisualStateManager.UseFluidLayout="True">
    			<VisualStateGroup.Transitions>
    				<VisualTransition GeneratedDuration="0:0:1">
    					<VisualTransition.GeneratedEasingFunction>
    						<CubicEase EasingMode="EaseInOut"/>
    					</VisualTransition.GeneratedEasingFunction>
    				</VisualTransition>
    			</VisualStateGroup.Transitions>
    			<VisualState x:Name="PageShown">
    				<Storyboard>
    					<DoubleAnimation Duration="0" To="-90" Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationX)" Storyboard.TargetName="chessBoard" d:IsOptimized="True"/>
    					<DoubleAnimation Duration="0" To="241" Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateY)" Storyboard.TargetName="chessBoard" d:IsOptimized="True"/>
    					<DoubleAnimation Duration="0" To="-90" Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationY)" Storyboard.TargetName="grid" d:IsOptimized="True"/>
    					<DoubleAnimation Duration="0" To="-240" Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateX)" Storyboard.TargetName="grid" d:IsOptimized="True"/>
    				</Storyboard>
    			</VisualState>
    			<VisualState x:Name="PageNormal"/>
    		</VisualStateGroup>
    	</VisualStateManager.VisualStateGroups>
        <Grid.RowDefinitions>
        	<RowDefinition Height="Auto"/>
        	<RowDefinition Height="*"/>
        </Grid.RowDefinitions>

    	<VisualStateManager.CustomVisualStateManager>
    		<ic:ExtendedVisualStateManager/>
    	</VisualStateManager.CustomVisualStateManager>

        <!--TitlePanel contains the name of the application and page title-->
        <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
            <TextBlock x:Name="ApplicationTitle" Text="{StaticResource appTitle}" Style="{StaticResource PhoneTextNormalStyle}"/>
        </StackPanel>

        <!--ContentPanel - place additional content here-->
        <Grid x:Name="ContentPanel" Grid.Row="1">
            <Grid.RowDefinitions>
                <RowDefinition Height="*" />
                <RowDefinition Height="480" />
            </Grid.RowDefinitions>
            <Grid x:Name="grid" HorizontalAlignment="Stretch" RenderTransformOrigin="0.5,0.5">
            	<Grid.RenderTransform>
            		<CompositeTransform/>
            	</Grid.RenderTransform>
            	<Grid.Projection>
            		<PlaneProjection/>
            	</Grid.Projection>
                <Grid.ColumnDefinitions>
                	<ColumnDefinition Width="Auto" />
                	<ColumnDefinition Width="290*" />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                	<RowDefinition Height="Auto" />
                	<RowDefinition Height="Auto" />
                </Grid.RowDefinitions>
                <TextBlock Grid.Row="0" Margin="3"><Run Text="Nodes/Sec:"/></TextBlock>
                <TextBlock x:Name="nodesSec" Grid.Column="1" Margin="3"/>
            </Grid>
            <wp7Chess:ChessBoard x:Name="chessBoard"
                                 HorizontalAlignment="Stretch"
                                 VerticalAlignment="Stretch"
                                 Grid.Row="1" RenderTransformOrigin="0.5,0.5" >
            	<wp7Chess:ChessBoard.RenderTransform>
            		<CompositeTransform/>
            	</wp7Chess:ChessBoard.RenderTransform>
            	<wp7Chess:ChessBoard.Projection>
            		<PlaneProjection/>
            	</wp7Chess:ChessBoard.Projection>
            </wp7Chess:ChessBoard>
            <Canvas x:Name="playerIntroPannel" Opacity="0.7">
                <Border x:Name="border" HorizontalAlignment="Center" VerticalAlignment="Top" Background="{StaticResource PhoneBackgroundBrush}" BorderBrush="{StaticResource PhoneBorderBrush}" BorderThickness="3" CornerRadius="30,1,30,10" RenderTransformOrigin="0.5,0.5" Canvas.Left="16" Canvas.Top="161" Width="451">
                	<Border.RenderTransform>
                		<CompositeTransform/>
                	</Border.RenderTransform>
                	<Border.Projection>
                		<PlaneProjection/>
                	</Border.Projection>
            		<TextBlock x:Name="tbPlayerTwoInfo"
            			TextWrapping="Wrap" 
            			Text="Computer (C#)" 
            			Foreground="{StaticResource PhoneAccentBrush}" 
            			FontSize="{StaticResource PhoneFontSizeExtraLarge}" Margin="7" HorizontalAlignment="Center" />
            	</Border>
            </Canvas>
            <Border x:Name="border1" HorizontalAlignment="Right" VerticalAlignment="Top" Background="{StaticResource PhoneBackgroundBrush}" BorderBrush="{StaticResource PhoneBorderBrush}" BorderThickness="3" CornerRadius="30,10,30,1" RenderTransformOrigin="0.5,0.5" Width="451" Margin="0,379,10,0" Grid.Row="1">
                <Border.RenderTransform>
                    <CompositeTransform />
                </Border.RenderTransform>
                <Border.Projection>
                    <PlaneProjection />
                </Border.Projection>
                <TextBlock x:Name="tbPlayerOneInfo" TextWrapping="Wrap" Text="Human" Foreground="{StaticResource PhoneAccentBrush}" FontSize="{StaticResource PhoneFontSizeExtraLarge}" Margin="7" HorizontalAlignment="Center" />
            </Border>
        </Grid>
    </Grid>
</phone:PhoneApplicationPage>